$(function(){
	//1.precode of javascript
	if($("#preJavascript").length>0&&$(".prettyprint").length>0){
		$(".prettyprint").text($("#preJavascript").text().replace(/(^\s*)|(\s*$)/g,""));
	}
	window.prettyPrint && prettyPrint();
	//2.toolTip of bootstrap
    $('.tooltip-test').tooltip({placement:"right",trigger:"hover"});
    //3.popover
	$(".icon-globe").popover({placement:"top",trigger:"click"})
			.click(function(e) {
			e.preventDefault()
 	}) ;
	$(".popover-test-close").live("click",function(e){
 			$(".icon-globe").popover('hide');
 			e.preventDefault();
 	});
    //4.iframe    
	$(".icon-eye-open").click(function() {
		var prevAHref = $(this).prev("a").attr("href");
		$.fancybox.open({
			href : prevAHref,
			type : 'iframe',
			padding : 5
		});
	 });
	//5.tab
	$('#myTab a').click(function (e) {
  		e.preventDefault();
  		$(this).tab('show');
	}) 
	//6.doc nav
	if($("#docNavList").length>0){
		var sections = $("section");
		$.each(sections,function(index,item){
			var p = $(item).children("p");
			var text = (p.text().length>16)?(p.text().substr(0,15)+"..."):p.text(); 
			$("#docNavList").append("<li class=''><a href='#"+$(item).attr('id')+"'><i class='icon-chevron-right'></i>"+text+"</a></li>");
		});
	}
	//7.html title
	var htmlTitle = $(".page-header h2");
	var htmlTitleText = "无题";
	if(htmlTitle != null && htmlTitle.text() != null && htmlTitle.text() != ""){
		htmlTitleText =  htmlTitle.text();
	}
	$("title").text(htmlTitleText);
});

/**
 * @author hjl
 * @description "console println";
 * @param title
 * @param content
 * @return
 */
function out(title,content){
	var outStr= "<div class='alert alert-info'>"+
    	"<button type='button' class='close' data-dismiss='alert'>&times;</button>"+
    	"<strong>"+title+":</strong> "+content+"."+
    "</div>";
	//<div class="alert alert-info"><button type='button' class='close' data-dismiss='alert'>&times;</button><strong>ÎÒÊÇÄ¬ÈÏÖµ:</strong></div>
	$(".container").append(outStr);
}